﻿using System;

namespace CSharp.Libs.Misc
{
    /// <summary>MessageItem</summary>
    /// <history>created  22.02.2012</history>
    public class MessageItem
    {
        #region declarations
        private int _intId = 0;
        private MessageType _mtType = MessageType.Information;
        private DateTime _dtOccured = DateTime.Now;
        private string _strText = "";

        private string _strSeparator = "|";
        private string _strDateTimeFormat = "dd.MM.yyyy HH:mm:ss";
        #endregion



        #region constructor / terminator
        public MessageItem(
            int intID,
            MessageType mtType,
            string strText)
        {
            _intId = intID;
            _mtType = mtType;
            _strText = strText;
        }

        public MessageItem(
            int intID,
            MessageType mtType,
            DateTime dtOccurred,
            string Text)
            : this(intID, mtType, Text)
        {
            _dtOccured = dtOccurred;
        }
        #endregion



        #region private functions
        #endregion



        #region interface
        #region properties
        #region message
        /// <summary>Id</summary>
        /// <remarks>message identifier. should be unique.</remarks>
        /// <history>created  22.02.2012</history>
        public int Id
        {
            get
            {
                return _intId;
            }
            set
            {
                _intId = value;
            }
        }

        /// <summary>Type</summary>
        /// <remarks>indicates the type of Message</remarks>
        /// <history>created  22.02.2012</history>
        public MessageType Type
        {
            get
            {
                return _mtType;
            }
            set
            {
                _mtType = value;
            }
        }

        /// <summary>Occured</summary>
        /// <remarks>DateTime value when message occured</remarks>
        /// <history>created  22.02.2012</history>
        public DateTime Occured
        {
            get
            {
                return _dtOccured;
            }
            set
            {
                _dtOccured = value;
            }
        }

        /// <summary>Text</summary>
        /// <remarks>main text of message</remarks>
        /// <history>created  22.02.2012</history>
        public string Text
        {
            get
            {
                return _strText;
            }
            set
            {
                _strText = value;
            }
        }
        #endregion

        #region settings
        /// <summary>Separator</summary>
        /// <remarks>sets the separator that separates the message values in the ToString() method</remarks>
        /// <history>created  22.02.2012</history>
        public string Separator
        {
            get
            {
                return _strSeparator;
            }
            set
            {
                _strSeparator = value;
            }
        }

        /// <summary>DateTimeFormat</summary>
        /// <remarks>sets the format of the Occured value in the ToString() method</remarks>
        /// <history>created  22.02.2012</history>
        public string DateTimeFormat
        {
            get
            {
                return _strDateTimeFormat;
            }
            set
            {
                _strDateTimeFormat = value;
            }
        }
        #endregion
        #endregion

        #region methods
        /// <summary>ToString</summary>
        /// <returns></returns>
        /// <history>created  22.02.2012</history>
        public override string ToString()
        {
            //return base.ToString();
            return _intId.ToString() + _strSeparator + _mtType.ToString() + _strSeparator + _dtOccured.ToString(_strDateTimeFormat) + _strSeparator + _strText;
        }
        #endregion
        #endregion
    }
}
